<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // var arrs = ['a','c','b','e','f'];
        // var a1 = arrs[0];
        // var a2 = arrs[1];
        // var a3 = arrs[2];
        // var a4 = arrs[3];
        // var a5 = arrs[4];
        // console.log(a1,a2,a3,a4,a5);

        // 以上是 以前的思路 把每个元素挨个放到指定的容器  
        // 下面是 解构的方式 
        // var [ a1,a2,a3,a4,a5 ] = arrs;
        // console.log(a1,a2,a3,a4,a5);


        // var arrs = [1,2,[3,4,[5,6,[7,8,[9]]]]]; // 五维数组  
        // var [a1,a2,[a3,a4,[a5,a6,[a7,a8,[a9]]]]] = arrs;
        // console.log(a1,a2,a3,a4,a5,a6,a7,a8,a9);


        // var arrs = ['a','b',['c','d']];

        // console.log(arrs[2][1]);


        var obj = {name:'zhangsan',age:18,height:'181cm'}
        // var name = obj.name; // obj['name']
        // var age = obj.age; // obj['age']
        // var height = obj.height; // obj['height']

        // console.log(name,age,height)


        // with(obj){
        //     var name = name; 
        //     var age = age; 
        //     var height = height;
        // }

        // console.log(name,age,height)


        // 解构 

        // var {name,age,height} = obj
        // console.log(name,age,height)


        
        // var {name:n,age:a,height} = obj
        // console.log(n,a,height); // 一旦起了别名 只能使用别名 不能使用原名字了 


        var  person = {
            name:'张三',
            age:18,
            gender:'男',
            child:{
                height:'100cm',
                weight:'30kg',
                hobby:['吃饭','睡觉','大豆豆'],
                address:{
                    city:'山东济南'
                }
            }
        }


        var {
            name,
            age:a,
            gender:g,
            child:{
                height,
                weight,
                hobby:h,
                address:{
                    city:c
                }
            }

        } = person;

        console.log(a,g,h,c)
    </script>
</body>
</html>